<div class="panel panel-default" ng-controller="nmap_Controller"><div class="panel-heading"><h4 class="panel-title pull-left">{{title}}</h4><span class="pull-right">{{version}}</span><div class="clearfix"></div></div></div>

<div class="row">
    <div class="col-md-4">
        <div class="panel panel-default" ng-controller="nmap_ControlsController">
            <div class="panel-heading">
				<h3 class="panel-title">Controls</h3>
            </div>
			<div class="panel-body">
				<table style="width:100%">
					<tr>
						<td style="padding-bottom: .5em;" class="text-muted">Dependencies</td>
            <td ng-hide="$root.status.installed" style="text-align:right;padding-bottom: .5em;"><button type="button" style="width: 90px;" class="btn btn-{{installLabel}} btn-xs" data-toggle="modal" data-target="#dependenciesInstallModal" ng-disabled="processing">{{install}}</button></td>
            <td ng-show="$root.status.installed" style="text-align:right;padding-bottom: .5em;"><button type="button" style="width: 90px;" class="btn btn-{{installLabel}} btn-xs" data-toggle="modal" data-target="#dependenciesRemoveModal" ng-disabled="processing">{{install}}</button></td>
					</tr>
					<tr ng-show="$root.status.installed">
						<td style="padding-bottom: .5em;" class="text-muted">nmap</td>
						<td style="text-align:right;padding-bottom: .5em;"><button type="button" style="width: 90px;" class="btn btn-{{statusLabel}} btn-xs" ng-disabled="starting || $root.command == 'nmap '" ng-click="togglenmap()">{{status}}</button></td>
					</tr>
				</table>
			</div>

      <div class="modal fade" id="dependenciesInstallModal" tabindex="-1" role="dialog" aria-labelledby="dependenciesModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="dependenciesInstallModalLabel">Install dependencies</h4>
            </div>
            <div class="modal-body">
              All required dependencies have to be installed first. This may take a few minutes.<br /><br />
              Please wait, do not leave or refresh this page. Once the install is complete, this page will refresh automatically.
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-info" ng-click="handleDependencies('internal')" data-dismiss="modal">Internal</button>
              <button type="button" class="btn btn-info" ng-hide="device == 'tetra' || sdAvailable == false" ng-click="handleDependencies('sd')" data-dismiss="modal">SD Card</button>
            </div>
          </div>
        </div>
      </div>

      <div class="modal fade" id="dependenciesRemoveModal" tabindex="-1" role="dialog" aria-labelledby="dependenciesModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="dependenciesRemoveModalLabel">Remove dependencies</h4>
            </div>
            <div class="modal-body">
              All required dependencies will be removed. This may take a few minutes.<br /><br />
              Please wait, do not leave or refresh this page. Once the remove is complete, this page will refresh automatically.
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
              <button type="button" class="btn btn-info" ng-click="handleDependencies()" data-dismiss="modal">Confirm</button>
            </div>
          </div>
        </div>
      </div>

        </div>
    </div>
</div>

<div class="panel panel-default" ng-show="$root.status.installed" ng-controller="nmap_OptionsController">
    <div class="panel-heading pointer" data-toggle="collapse" data-target="#Options">
        <h4 class="panel-title">Options</h4>
    </div>
    <div id="Options" class="panel-collapse collapse">
	    <div class="panel-body">

          <div class="form-group">
              <div class="input-group">
                  <span class="input-group-addon input-sm">Command</span>
                  <input type="text" class="form-control input-sm" ng-model="command" placeholder="nmap command">
              </div>
          </div>

          <div class="form-group">
              <div class="input-group">
                  <span class="input-group-addon input-sm">Target</span>
                  <input ng-change="update()" type="text" class="form-control input-sm" ng-model="target" placeholder="Target">
              </div>
          </div>

          <div class="form-group">
              <div class="input-group">
                <span class="input-group-addon input-sm">Profile</span>
                <select ng-change="update()" ng-model="profile" class="form-control input-sm">
                  <option>--</option>
                  <option value="">Regular scan</option>
                  <option value="-T4 -A -v">Intense scan</option>
                  <option value="-sS -sU -T4 -A -v">Intense scan plus UDP</option>
                  <option value="-p 1-65535 -T4 -A -v">Intense scan, all TCP ports</option>
                  <option value="-T4 -A -v -Pn">Intense scan, no ping</option>
                  <option value="-sn">Ping scan</option>
                  <option value="-T4 -F">Quick scan</option>
                  <option value="-sV -T4 -O -F --version-light">Quick scan plus</option>
                  <option value="-sn --traceroute">Quick traceroute</option>
                  <option value="-sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53">Slow comprehensive scan</option>
                </select>
              </div>
          </div>

          <div ng-show="profile=='--'" class="panel panel-default">
              <div class="panel-heading pointer" data-toggle="collapse" data-target="#Scan">Scan</div>
              <div id="Scan" class="panel-collapse collapse">
                <div class="panel-body">

                  <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon input-sm">Timing</span>
                        <select ng-change="update()" ng-model="timing" class="form-control input-sm">
                          <option>--</option>
                          <option value="-T0">Paranoid</option>
                          <option value="-T1">Sneaky</option>
                          <option value="-T2">Polite</option>
                          <option value="-T3">Normal</option>
                          <option value="-T4">Aggresive</option>
                          <option value="-T5">Insane</option>
                        </select>
                      </div>
                  </div>

                  <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon input-sm">TCP scan</span>
                        <select ng-change="update()" ng-model="tcp" class="form-control input-sm">
                          <option>--</option>
                          <option value="-sA">ACK scan</option>
                          <option value="-sF">FIN scan</option>
                          <option value="-sM">Maimon scan</option>
                          <option value="-sN">Null scan</option>
                          <option value="-sS">TCP SYN scan</option>
                          <option value="-sT">TCP connect scan</option>
                          <option value="-sW">Window scan</option>
                          <option value="-sX">Xmas Tree scan</option>
                        </select>
                      </div>
                  </div>

                  <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon input-sm">Non-TCP scan</span>
                        <select ng-change="update()" ng-model="nontcp" class="form-control input-sm">
                          <option>--</option>
                          <option value="-sU">UDP scan</option>
                          <option value="-sO">IP protocol scan</option>
                          <option value="-sL">List scan</option>
                          <option value="-sn">No port scan</option>
                          <option value="-sY">SCTP INIT port scan</option>
                          <option value="-sZ">SCTP cookie-echo port scan</option>
                        </select>
                      </div>
                  </div>

                  <div class="form-group">
                      <div class="input-group">
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="scanOptions.option1" ng-true-value="'-A'"> Enable all advanced/aggressive options</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="scanOptions.option2" ng-true-value="'-O'"> OS detection</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="scanOptions.option3" ng-true-value="'-sV'"> Version detection</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="scanOptions.option4" ng-true-value="'-n'"> Disable reverse DNS resolution</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="scanOptions.option5" ng-true-value="'-6'"> IPv6 support</label></div>
                      </div>
                  </div>
                </div>
              </div>
          </div>

          <div ng-show="profile=='--'" class="panel panel-default">
              <div class="panel-heading pointer" data-toggle="collapse" data-target="#Ping">Ping</div>
              <div id="Ping" class="panel-collapse collapse">
                <div class="panel-body">
                  <div class="form-group">
                      <div class="input-group">
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="pingOptions.option1" ng-true-value="'-Pn'"> No ping before scanning</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="pingOptions.option2" ng-true-value="'-PE'"> ICMP ping</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="pingOptions.option3" ng-true-value="'-PP'"> ICMP timestamp request</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="pingOptions.option4" ng-true-value="'-PM'"> ICMP netmask request</label></div>
                      </div>
                  </div>
                </div>
              </div>
          </div>

          <div ng-show="profile=='--'" class="panel panel-default">
              <div class="panel-heading pointer" data-toggle="collapse" data-target="#Target">Target</div>
              <div id="Target" class="panel-collapse collapse">
                <div class="panel-body">
                  <div class="form-group">
                      <div class="input-group">
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="targetOptions.option1" ng-true-value="'-F'"> Fast scan</label></div>
                      </div>
                  </div>
                </div>
              </div>
          </div>

          <div ng-show="profile=='--'" class="panel panel-default">
              <div class="panel-heading pointer" data-toggle="collapse" data-target="#Other">Other</div>
              <div id="Other" class="panel-collapse collapse">
                <div class="panel-body">
                  <div class="form-group">
                      <div class="input-group">
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="otherOptions.option1" ng-true-value="'-f'"> Fragment IP packets</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="otherOptions.option2" ng-true-value="'--packet-trace'"> Packet trace</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="otherOptions.option3" ng-true-value="'-r'"> Disable randomizing scanned ports</label></div>
                        <div class="checkbox"><label><input type="checkbox" ng-change="update()" ng-model="otherOptions.option4" ng-true-value="'--traceroute'"> Trace routes to targets</label></div>
                      </div>
                  </div>
                </div>
              </div>
          </div>

	    </div>
	</div>
</div>

<div class="panel panel-default" ng-show="$root.status.installed" ng-controller="nmap_OutputController">
	<div class="panel-heading">
        <h4 class="panel-title pull-left">Output</h4>
		<div class="pull-right">
			Auto-refresh <div class="btn-group">
			<button ng-click="toggleAutoRefresh()" class="btn btn-xs btn-{{refreshLabelON}}">ON</button>
			<button ng-click="toggleAutoRefresh()" class="btn btn-xs btn-{{refreshLabelOFF}}">OFF</button>
			</div>
		</div>
		<div class="clearfix"></div>
    </div>
    <div class="panel-body">
        <button class="btn btn-primary btn-sm pull-right" ng-click="refreshOutput()">Refresh Scan</button><div class="clearfix"></div>
		<pre class="scrollable-pre log-pre">{{output}}</pre>
    </div>
</div>

<div class="panel panel-default" ng-show="$root.status.installed" ng-controller="nmap_HistoryController">
    <div class="panel-heading pointer" data-toggle="collapse" data-target="#History">
        <h4 class="panel-title">History <span class="badge">{{history.length}}</span></h4>
    </div>
    <div id="History" class="panel-collapse collapse">
        <div class="panel-body">
	        <button class="btn btn-primary btn-sm pull-right" ng-click="refreshHistory()">Refresh History</button><div class="clearfix"></div>
			<div class="table-responsive">
	            <table class="table table-striped table-bordered table-hover" ng-hide="(history.length == 0)">
	                <thead>
	                    <tr>
	                        <th>Date</th>
	                        <th>Action</th>
	                    </tr>
	                </thead>
	                <tbody>
	                    <tr ng-repeat="entry in history" ng-if="entry != ''">
	                        <td>{{entry[0]}}</td>
	                        <td>
								<div class="btn-group">
									<button type="button" class="btn btn-fixed-length btn-sm btn-default" data-toggle="modal" data-target="#historyModal" ng-click="viewHistory(entry[1])">View</button>
									<button type="button" class="btn btn-sm btn-default" ng-click="downloadHistory(entry[1])">Download</button>
                  <button type="button" class="btn btn-fixed-length btn-sm btn-danger" ng-click="deleteHistory(entry[1])">Delete</button>
								</div>
							</td>
	                    </tr>
	                </tbody>
	            </table>
	        </div>
			<div class="well" ng-show="(history.length === 0)">No history...</div>
        </div>
    </div>

	<div class="modal fade" id="historyModal" tabindex="-1" role="dialog" aria-labelledby="historyModalLabel">
	  <div class="modal-dialog modal-lg" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="historyModalLabel">View History - {{historyDate}}</h4>
	      </div>
	      <div class="modal-body">
	      <pre class="scrollable-pre log-pre">{{historyOutput}}</pre>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	      </div>
	    </div>
	  </div>
	</div>

</div>
